1 module unde.keybar.lib; 2 3 import derelict.sdl2.sdl; 4 import derelict.sdl2.ttf; 5 import derelict.sdl2.image; 6 7 import unde.global_state; 8 import unde.slash; 9 10 import std.stdio; 11 import std.string; 12 import std.math; 13 import std.range.primitives; 14 import std.file; 15 import std.algorithm.sorting; 16 import std.process; 17 import core.stdc.locale; 18 import core.sys.windows.windows; 19 20 struct KeyHandler 21 { 22 void delegate (GlobalState gs) handler; 23 string description; 24 string icon; 25 26 void handle(GlobalState gs) 27 { 28 handler(gs); 29 } 30 } 31 32 struct ButtonParms 33 { 34 SDL_Rect rect; 35 SDL_Color color; 36 } 37 38 struct ButtonPos 39 { 40 ushort i; 41 ushort pos; 42 } 43 44 class KeyBar_Buttons 45 { 46 private 47 SDL_Renderer *renderer; 48 49 bool input_mode; 50 byte rec_input_mode = -1; 51 52 string[] layout_names; 53 54 KeyHandler[int] handlers; 55 KeyHandler[int] handlers_down; 56 KeyHandler[int] handlers_double; 57 58 void delegate (GlobalState gs)[string] macros_handlers; 59 string[void delegate (GlobalState gs)] handlers_macros; 60 61 SDL_Scancode[][3] *scans_cur; 62 SDL_Scancode[][3] scans; 63 SDL_Scancode[][3] scans_altgr; 64 ButtonPos[SDL_Scancode] buttonpos_by_scan; 65 ButtonPos[SDL_Scancode] buttonpos_by_scan_altgr; 66 67 this(GlobalState gs, SDL_Renderer *renderer, string start_cwd) 68 { 69 this.renderer = renderer; 70 SDL_StopTextInput(); 71 } 72 } 73